/*****************************************************************************
* | File      	: DEV_Config.h
* | Author      : Waveshare team
* | Function    :	debug with prntf
* | Info        :
*   Image scanning
*      Please use progressive scanning to generate images or fonts
*----------------
* |	This version:   V1.0
* | Date        :   2018-01-11
* | Info        :   Basic version
*
******************************************************************************/
#ifndef _DEV_CONFIG_H_
#define _DEV_CONFIG_H_

#include <stdint.h>

/**
 * data
**/
#define UBYTE   uint8_t
#define UWORD   uint16_t
#define UDOUBLE uint32_t

#define GPIO_PIN_RESET 0
#define GPIO_PIN_SET   1

enum {
    EPD_CS_PIN,
    EPD_DC_PIN,
    EPD_RST_PIN,
    EPD_BUSY_PIN,
    RAM_CS_PIN,
    SD_CS_PIN,
    EPD_DEV_PIN_MAX,
};

/**
 * GPIO read and write
**/
void DEV_Digital_Write(uint8_t id, uint8_t value);
uint8_t DEV_Digital_Read(uint8_t id);

/**
 * delay x ms
**/
#define DEV_Delay_ms(__xms) rt_thread_mdelay(__xms);

/**
 * SPI RAM
**/
#define SPIRAM_CS_0     DEV_Digital_Write(RAM_CS_PIN, GPIO_PIN_RESET)
#define SPIRAM_CS_1     DEV_Digital_Write(RAM_CS_PIN, GPIO_PIN_SET)

/**
 * SD Card
**/
#define SD_CS_0         DEV_Digital_Write(SD_CS_PIN, GPIO_PIN_RESET)
#define SD_CS_1         DEV_Digital_Write(SD_CS_PIN, GPIO_PIN_SET)

/**
 * e-Paper GPIO
**/
#define EPD_CS_0		DEV_Digital_Write(EPD_CS_PIN, GPIO_PIN_RESET)
#define EPD_CS_1		DEV_Digital_Write(EPD_CS_PIN, GPIO_PIN_SET)

#define EPD_DC_0		DEV_Digital_Write(EPD_DC_PIN, GPIO_PIN_RESET)
#define EPD_DC_1		DEV_Digital_Write(EPD_DC_PIN, GPIO_PIN_SET)

#define EPD_RST_0		DEV_Digital_Write(EPD_RST_PIN, GPIO_PIN_RESET)
#define EPD_RST_1		DEV_Digital_Write(EPD_RST_PIN, GPIO_PIN_SET)

#define EPD_BUSY_RD		DEV_Digital_Read(EPD_BUSY_PIN)

UBYTE DEV_Module_Init(void);
void DEV_Module_Exit(void);

void DEV_SPI_WriteByte(UBYTE value);
UBYTE DEV_SPI_ReadByte(void);
//uint8_t DEV_SPI_WriteReadByte(uint8_t value);

void DEV_Delay_us(UWORD xus);


#endif
